package com.entor.util;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;

public class HighCharts {
	
	/**
	 * 生成highchar普通柱状图
	 * @param map 包含title(标题)，subtitle(小标题)，yAxis(y轴文字)
	 * @param categories 
	 * @param series 包含name(String),data[]
	 * @return
	 */
	public static String createColumn(Map<String, String> map,String[] categories,List<Map<String, Object>> series){
		StringBuilder sb = new StringBuilder("{");
		sb.append("\"chart\": {")
			.append("\"type\":\"column\"},")
	        .append("\"title\":{\"text\":\""+map.get("title")+"\"},")
	        .append("\"subtitle\":{\"text\": \""+map.get("subtitle")+"\"},")
			.append("\"xAxis\": {\"categories\": ")
			.append(JSON.toJSONString(categories))
			.append(",\"crosshair\": true},")
            .append("\"yAxis\": {\"min\": 0,\"title\": {\"text\": \""+map.get("yAxis")+"\"}},")
            .append("\"tooltip\": {},")
            .append("\"credits\": {\"enabled\":false},")
            .append("\"plotOptions\": {\"column\": {\"pointPadding\": 0.2,\"borderWidth\": 0}},")
            .append("\"series\":")
            .append(JSON.toJSONString(series));
		sb.append("}");
		return sb.toString();
	}

}
